/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.model;

import java.util.ArrayList;

/**
 *
 * @author Natalie
 */
public class TicketComposite extends TicketComponent
{
    private ArrayList tickets = new ArrayList();

    public void addTicket(TicketComponent ticket)
    {
        tickets.add(ticket);
    }


    public void bookTicket(String bookingNum)
    {
        System.out.println("Composite of Tickets being booked");
        for(int i = 0; i<tickets.size(); i++)
        {
           TicketComponent comp = (TicketComponent) tickets.get(i);
           comp.bookTicket(bookingNum);
        }
    }

    public double getCost()
    {
        double cost = 0;

        for(int i = 0; i<tickets.size(); i++)
        {
           TicketComponent comp = (TicketComponent) tickets.get(i);
           cost += comp.getCost();
        }

        return cost;
    }
}
